package models

import (
	"backend/internal/biz"
	"time"

	"gorm.io/gorm"
)

type User struct {
	ID        uint           `gorm:"primarykey"`
	UserName  string         `json:"username" gorm:"column:user_name;not null;default:'';comment:用户名"`
	Password  string         `json:"password" gorm:"column:password;not null;default:'';comment:用户密码"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
}

func (m *User) ToBiz() *biz.User {
	return &biz.User{
		ID:        uint64(m.ID),
		UserName:  m.UserName,
		Password:  m.Password,
		CreatedAt: m.CreatedAt,
		UpdatedAt: m.UpdatedAt,
	}
}
